{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "import torch.nn as nn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[0.0000e+00, 0.0000e+00, 3.3497e-09],\n",
       "        [2.1027e+20, 3.3856e-06, 1.6987e-07]])"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "torch.Tensor(2, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Parameter containing:\n",
       "tensor([[6.7262e-44, 7.9874e-44, 1.1771e-43],\n",
       "        [6.7262e-44, 7.1466e-44, 8.1275e-44]], requires_grad=True)"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nn.Parameter(torch.Tensor(2,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[ 0.7628, -1.6425, -1.4857],\n",
       "        [ 0.4624,  0.4417, -1.0390]])"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b = torch.randn(2,3)\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[0.4614, 0.1125, 0.6703],\n",
       "        [0.1231, 0.2875, 0.3648]])"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b.uniform_(0, 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[0., 0., 0.],\n",
       "        [0., 0., 0.]])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c = torch.zeros(2,3)\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([2, 3])"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c.size()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[[0., 0., 0.],\n",
       "         [0., 0., 0.]]])"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c = c.unsqueeze(0)\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([1, 2, 3])"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c.size()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[ 1.0085,  1.3747, -1.2875,  0.8424],\n",
      "        [-0.2851, -1.5225, -1.1119, -1.5243],\n",
      "        [-0.4864,  0.8463, -0.5516,  0.2596]])\n",
      "tensor([[-0.8208, -1.9864, -1.3729, -0.5153],\n",
      "        [-0.7217,  0.5975,  1.1512,  1.1755],\n",
      "        [ 0.6672, -1.9025, -0.6683, -0.4970]])\n",
      "[]\n"
     ]
    }
   ],
   "source": [
    "t1 = torch.randn(3,4)\n",
    "t2= torch.randn(3,4)\n",
    "l1 = []\n",
    "print(t1)\n",
    "print(t2)\n",
    "print(l1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[tensor([[[ 1.0085,  1.3747, -1.2875,  0.8424],\n",
       "          [-0.2851, -1.5225, -1.1119, -1.5243],\n",
       "          [-0.4864,  0.8463, -0.5516,  0.2596]]]),\n",
       " tensor([[[-0.8208, -1.9864, -1.3729, -0.5153],\n",
       "          [-0.7217,  0.5975,  1.1512,  1.1755],\n",
       "          [ 0.6672, -1.9025, -0.6683, -0.4970]]])]"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "l1.append(t1.unsqueeze(0))\n",
    "l1.append(t2.unsqueeze(0))\n",
    "l1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[[ 1.0085,  1.3747, -1.2875,  0.8424],\n",
       "         [-0.2851, -1.5225, -1.1119, -1.5243],\n",
       "         [-0.4864,  0.8463, -0.5516,  0.2596]],\n",
       "\n",
       "        [[-0.8208, -1.9864, -1.3729, -0.5153],\n",
       "         [-0.7217,  0.5975,  1.1512,  1.1755],\n",
       "         [ 0.6672, -1.9025, -0.6683, -0.4970]]])"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "l1 = torch.cat(l1,dim=0)\n",
    "l1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([2, 3, 4])"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "l1.size()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[[ 1.0085,  1.3747, -1.2875,  0.8424],\n",
       "         [-0.8208, -1.9864, -1.3729, -0.5153]],\n",
       "\n",
       "        [[-0.2851, -1.5225, -1.1119, -1.5243],\n",
       "         [-0.7217,  0.5975,  1.1512,  1.1755]],\n",
       "\n",
       "        [[-0.4864,  0.8463, -0.5516,  0.2596],\n",
       "         [ 0.6672, -1.9025, -0.6683, -0.4970]]])"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "l1.transpose(0,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[-1.4251, -0.5673, -0.3780],\n",
       "        [ 0.4909, -0.6237, -1.4178]])"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = torch.randn(2,3)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[-1.4251,  0.4909],\n",
       "        [-0.5673, -0.6237],\n",
       "        [-0.3780, -1.4178]])"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.transpose(0,1)"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "04546e26b63e01885cb4eec61ef38c0809d8f2802367581d36ec2bd0dbc452e8"
  },
  "kernelspec": {
   "display_name": "Python 3.8.12 64-bit ('torch_env': conda)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.12"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
